package com.woupla.security;

import org.jboss.seam.security.Identity;
import org.jboss.seam.security.annotations.Secures;

import com.woupla.account.Authenticated;

public class SecurityRules {
	  public
	    @Secures
	    @Admin
	    boolean adminChecker(Identity identity) {
	        if (identity.getUser() == null) {
	            return false;
	        } else {
	            return "admin".equals(identity.getUser().getId());
	        }
	    }
	    
	    @Secures
	    @Authenticated
	    public boolean loggedInChecker(Identity identity) {
	    	if (identity == null) {
	            return false;
	        } else {
	        return identity.isLoggedIn();
	        }
	    }
	    
	    @Secures
	    @Employee
	    public boolean employeeChecker(Identity identity) {
	    	if (identity == null) {
	            return false;
	        } else {	        	
	        return identity.inGroup("EMPLOYEE", "GROUP");
	        }
	    }
	    @Secures
	    @Manager
	    public boolean managerChecker(Identity identity) {
	    	if (identity == null) {
	            return false;
	        } else {	        	
	        return identity.hasRole("Manager", "EMPLOYEE", "GROUP");
	        }
	    }
}
